minstant
A drop-in replacement for std::time::Instant
that measures time with high performance and high accuracy powered by TSC.
Usage
[]
= "0.1"
let start = now;
// Code snipppet to measure
let duration: Duration = start.elapsed;
Motivation
This library is used by a high performance tracing library minitrace-rust
. The main purpose is to use TSC on x86 processors to measure time at high speed without losing much accuracy.
Platform Support
Currently, only the Linux on x86
or x86_64
is backed by TSC. On other platforms, minstant
falls back to std::time
. If TSC is unstable, it will also fall back to std::time
.
If speed is privileged over accuracy when fallback occurs, you can use fallback-corase
feature to use corase time:
[]
= { = "0.1", = ["fallback-coarse"] }
Benchmark
Benchmark platform is Intel(R) Xeon(R) CPU E5-2630 v4 @ 2.20GHz
on CentOS 7.
> cargo